<?php

namespace App\Http\Controllers\Api;

use App\Http\Requests\Api\ResetPasswordRequest;

class ResetPasswordController extends Controller
{
    public function update(ResetPasswordRequest $request)
    {
        // 校验验证码
        $res = VerificationCodesController::verify($request->user_mobile, $request->sms_key, $request->sms_code);

        if ($res['response'] != 'success') {
            $response = $res['response'];
            $message = $res['message'];

            return $this->$response($message);
        }

        $user = auth('api')->user();

        $user->password = $request->password;
        $user->save();

        return $this->success();

    }
}
